using System;
using Slaks.Descriptions;

namespace Slaks.Filters
{
	/// <summary>
	/// Cyrillic character filter
	/// </summary>
	[ModuleDescription("Cyrillic character filter","Slava Kisilevich")]
	public class RussianFilter : AFilter
	{

		protected static readonly int RussianNotInRangeFirstEnd = 0x40f;
		protected static readonly int RussianNotInRangeSecondStart = 0x480;

		public RussianFilter()
		{
		}

		/// <summary>
		/// If the character is one that is defined as 'space' character, then return true
		/// Each language has its own characters that can be defined as space characters
		/// For example : in english it can be '\t', ' '
		/// </summary>
		/// <param name="ch">character to check</param>
		/// <returns>true/false</returns>
		public override bool IsWhiteSpace(char ch)
		{
			if (ch <= RussianNotInRangeFirstEnd || ch >= RussianNotInRangeSecondStart) return true;
			return false;
		}

		public override bool IsEndOfSentencePunctuationMark(char ch)
		{
			if (ch == GeneralEndOfSentencePunctuationMarkDot ||
				  ch == GeneralEndOfSentencePunctuationMarkExclamation ||
				  ch == GeneralEndOfSentencePunctuationMarkQuestion) return true;

			return false;
		}

		public override bool IsMiddleSentencePunctuationMark(char ch)
		{
			if (ch == GeneralMiddleOfSentencePunctuationMarkComma) return true;
			return false;
		}


		/// <summary>
		/// Normalization of the character
		/// Example: Capital letter convert to low
		/// </summary>
		/// <param name="ch">normalized character</param>
		/// <returns>char</returns>
		public override char Normalize(char ch)
		{
			return char.ToLower(ch);
		}

		public override string ToString()
		{
			return "Cyrillic character filter";
		}

	}
}
